/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package connection;

import java.net.DatagramSocket;
import java.net.InetAddress;
import server.*;

/**
 *
 * @author rmb
 */
public class Connection {
    
    private DatagramSocket socket;
    
    private static DataReceive receive;
    private static DataSend send;
    
    public Connection(DatagramSocket sock, int port, InetAddress addr) {
        
        this.socket = sock;
        receive = new DataReceive(socket);
        send = new DataSend(socket, addr, port);
    }
    
    public void start() {
        receive.start();
        send.start();
    }

    public void endConnection() {
        receive.setStop();
        send.setStop();
        socket.close();
        System.out.println("Connection has been closed");
    }

    public DataReceive getReceive() {
        return receive;
    }

    public DataSend getSend() {
        return send;
    }

    public DatagramSocket getSocket() {
        return socket;
    }
        
    
    public void setReceive(DataReceive receive) {
        Connection.receive = receive;
    }

    public void setSend(DataSend send) {
        Connection.send = send;
    }

    public void setSocket(DatagramSocket socket) {
        this.socket = socket;
    }
    
    
    
    
}
